﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>班级信息管理</title>
    <#--引入的一些核心文件-->
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn-input').click(function () {
                var json = $(this).data('json');
                if(json){
                    $('input[name=id]').val(json.id);
                    $('input[name=name]').val(json.name);
                    $('input[name=number]').val(json.number);
                    $('#employee').val(json.employee.id);
                }else{
                    $('#editForm input').val('');
                    $('#employee').val(-1);
                }
                $('#myModal').modal('show');
            });


            //提交表单
            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.alert("温馨提示","保存成功!1s后自动关闭")
                        window.setTimeout(function () {
                            window.location.href='/classInfo/list.do'
                        },1000)
                    }else{
                        $.messager.popup(data.msg)
                    }
                });
            })

            //确定删除
            $('.btn-delete').click(function () {
                var id = $(this).data('id');
                $.messager.confirm('提示','是否确认删除',function () {
                    $.get('/classInfo/delete.do',{id:id},handleMessage)
                })
            })
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <#assign currentMenu="classInfo">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>班级信息管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-inline" id="searchForm" action="/classInfo/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入班级名">
                    </div>
                    <div class="form-group">
                        <label for="empId"> 班主任:</label>
                        <select class="form-control" id="empId" name="empId">
                            <option value="-1">全部</option>
                                <#list employees as e>
                                    <option value="${e.id}">${(e.name)!}</option>
                                </#list>
                        </select>
                    <#--回显选中的班主任-->
                        <script>
                            $('#empId').val(${(qo.empId)!});
                        </script>
                    </div>
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>班级名称</th>
                            <th>班级人数</th>
                            <th>班主任</th>
                            <th>操作</th>
                        </tr>
                        <#list result.list as classInfo>
                            <tr>
                                <td>${classInfo_index+1}</td>
                                <td>${classInfo.name!}</td>
                                <td>${classInfo.number!}</td>
                                <td>${(classInfo.employee.name)!}</td>
                                <td>
                                    <a href="#" class="btn btn-info btn-xs btn-input" data-json='${classInfo.json!}' >
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a href="#" class="btn btn-danger btn-xs btn-delete" data-id="${classInfo.id}">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
        <#--引入主页面的底部(一些公司的信息)-->
    <#include "../common/footer.ftl">
</div>

<!-- 模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/classInfo/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden"  name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">班级名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name"
                                   placeholder="请输入班级名">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="number" class="col-sm-3 control-label">班级人数：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number"
                                   placeholder="请输入班级人数">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="employee" class="col-sm-3 control-label">班主任：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="employee" name="employee.id">
                                <option value="-1">全部</option>
                                <#list employees as e>
                                    <option value="${e.id}">${e.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
